package com.zhuiyun.project.api.articlereport.service.impl;


import com.zhuiyun.project.api.articlereport.mapper.ReportMapper;
import com.zhuiyun.project.api.articlereport.model.ReportModel;
import com.zhuiyun.project.api.articlereport.service.ReportService;

import com.zhuiyun.project.api.dict.entity.DictData;
import com.zhuiyun.project.util.pageUtil.MybatisPageHelper;
import com.zhuiyun.project.util.pageUtil.PageRequest;
import com.zhuiyun.project.util.pageUtil.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @ClassName ArticleServiceImpl
 * @Description TODO
 * @Author 韩佳轩
 * @Date 2023/6/15 10:34
 **/
@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private ReportMapper reportMapper;
    @Override
    public PageResult reportAll(ReportModel reportModel, PageRequest pageRequest) {
        MybatisPageHelper.startPage(pageRequest);
        PageResult pageResult = MybatisPageHelper.getPageResult(reportMapper.reportAll(reportModel));
        return pageResult;
    }

    @Override
    public int updateAgree(int id,String processorName,String rejectionReason) {
        return reportMapper.updateAgree(id,processorName,rejectionReason);
    }

    @Override
    public int updateReject(ReportModel reportModel) {
        return reportMapper.updateReject(reportModel);
    }

    @Override
    public int addReport(ReportModel reportModel) {
        Date date=new Date();
        reportModel.setReportTime(date);
        reportModel.setCreateTime(date);
        reportModel.setUpdateTime(date);
        reportModel.setReportStatus(2);
        reportModel.setDelFlag(0);
        return reportMapper.addReport(reportModel);
    }

    @Override
    public List<DictData> getReportType(DictData dictData) {
        return reportMapper.getReportType(dictData);
    }
}
